package tju.mic.medicine.ws.resource;

import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.MediaType;
import tju.mic.medicine.ws.models.Department;
import tju.mic.medicine.ws.models.DepartmentList;
import tju.mic.medicine.ws.service.DiseaseService;
import tju.mic.utils.ApplicationContextProvider;

/**
 *
 * @author Patrick
 */
@Path("depart")
public class DepartResource {
    private DiseaseService diseaseService = ApplicationContextProvider.getApplicationContext().getBean(DiseaseService.class);
    
    @GET
    @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
    public Department getById(@QueryParam("sid")String sid,@QueryParam("did")Long departId) throws Exception{
        return diseaseService.getDepartById(departId);
    }
    
    @GET
    @Path("all")
    @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
    public DepartmentList getAll(@QueryParam("sid")String sid) throws Exception{
        return diseaseService.getAllDepart();
    }
}
